tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
mdatafilename='Mfile_pn390.csv'
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
tmp_TP2
tmp_TP2["be"]
time
index<-which(tmp_TP2==time)
index
names(X)
unique(tmp_TP2)
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
View(X_req)
colnames(X_req[["baseline:caprion_panel1"]])
colnames(X_req[["week 1:caprion_panel2"]])
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
## Getting the phenotype information
Y<-as.numeric(X_req[[1]][,1]) # this is should be numeric 0 and 1 for classification
Y<-Y-1
X<-X_req
## Getting data in matrix form and removing the Y and subject ID
for(N in names(X_req)){
X[[N]]<-as.matrix(X_req[[N]][,-c(1,ncol(X_req[[N]]))])
}
## Concatenating all Data into a Matrix
req_con_mat<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
tmp<-as.matrix(X_req[[N]])
tmp_req_con_mat<-cbind(tmp_req_con_mat,tmp)
}
req_con_mat[[time]]<-tmp_req_con_mat
}
names(X)<-tmp_names
colnames(req_con_mat[["m2"]])
colnames(req_con_mat[["m1"]])
colnames(req_con_mat[["w1"]])
Read_input_data_VSURF_mFile = function(mFile) {
# load data manifest
mfst <- read.csv(mFile,sep = ',', header = TRUE,stringsAsFactors=FALSE)
# check that every filename is real
xst <- file.exists(mfst$Filename)
if (!all(xst)) {
stpstr <- 'The following file names are incorrect:'
for (fnm in mfst[which(xst == F),'Filename']) {
stpstr <- paste0(stpstr, '\n\t', '* ', fnm)
}
stop(stpstr, call.=F)
}
# load data
X <- lapply(mfst$Filename, function(x) read.csv(x))
# give each member of data list name
names(X) <- mfst$Timepoint
return(X)
}
mFile
Seed<-Read_input_data_VSURF_mFile(mFile)
View(Seed)
tmp_TP<-names(Seed)
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
names(Seed)<-tmp_TP2
req_Seed<-Seed
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_seed_f<-as.character(Seed[[time]][which(Seed[[time]][,2]>45),1])
tmp_seed_f<-paste0(tmp_seed_f,'_',time)
req_Seed[[time]]<-tmp_seed_f
}
View(req_Seed)
colnames(req_con_mat[['be']])
intersect(colnames(req_con_mat[['be']]),req_Seed[['be']])
Seed[["month 1"]]
Seed[["month 1"]]
Seed[["baseline"]]
Seed[["baseline"]][["Feature"]]
Seed<-Read_input_data_VSURF_mFile(mVSURFfilename)
VSURFfilename='Mfile_pn390_VSURF.csv'
Seed<-Read_input_data_VSURF_mFile(mVSURFfilename)
mVSURFfilename='Mfile_pn390_VSURF.csv'
Seed<-Read_input_data_VSURF_mFile(mVSURFfilename)
View(Seed)
Seed[["baseline"]]
A<-read.csv("/Users/thakurgu/Downloads/VSURF_FreqTable_baseline_set2.csv")### to be removed
seed_f<-as.character(A[which(A[,2]>45),1])
Seed[["month 1"]]
X<-Read_input_data_from_mFile(mdatafilename)
View(X)
names(X)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
tmp_names
sht_tmp_names<-paste0(substr(tmp_names,1,1),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
sht_tmp_names
sht_tmp_names<-paste0(substr(tmp_names,1,3),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
sht_tmp_names
names(X)
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
sht_tmp_names<-paste0(substr(tmp_names,1,3),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
tmp_N<-strsplit(N,":")[[1]][2]
tmp_N2<-paste0(substr(tmp_N,1,3),substr(tmp_N,nchar(tmp_N),nchar(tmp_N)))
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'::',tmp_N2,'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
View(X_req)
colnames(X_req[["baseline:BTMs"]])
colnames(X_req[["month 2:mibig"]])
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
sht_tmp_names<-paste0(substr(tmp_names,1,3),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
tmp_N<-strsplit(N,":")[[1]][2]
tmp_N2<-paste0(substr(tmp_N,1,3),substr(tmp_N,nchar(tmp_N),nchar(tmp_N)))
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'::',tmp_N2,'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
## Getting the phenotype information
Y<-as.numeric(X_req[[1]][,1]) # this is should be numeric 0 and 1 for classification
Y<-Y-1
X<-X_req
## Getting data in matrix form and removing the Y and subject ID
for(N in names(X_req)){
X[[N]]<-as.matrix(X_req[[N]][,-c(1,ncol(X_req[[N]]))])
}
## Concatenating all Data into a Matrix
req_con_mat<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
tmp<-as.matrix(X_req[[N]])
tmp_req_con_mat<-cbind(tmp_req_con_mat,tmp)
}
req_con_mat[[time]]<-tmp_req_con_mat
}
names(X)<-tmp_names
head(req_con_mat)
X_req[["month 1:metabolomics_plasma"]][1,1:10]
colnames(X_req[["month 1:metabolomics_plasma"]])[2]]
colnames(X_req[["month 1:metabolomics_plasma"]])[2]
colnames(X[["month 1:metabolomics_plasma"]])[2]
names(X)
colnames(X[["month 1:metabolomics_plasma"]])[2]
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
sht_tmp_names<-paste0(substr(tmp_names,1,3),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
tmp_N<-strsplit(N,":")[[1]][2]
tmp_N2<-paste0(substr(tmp_N,1,3),substr(tmp_N,nchar(tmp_N),nchar(tmp_N)))
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'::',tmp_N2,'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
names(X)
X[["baseline:metabolomics_plasma"]][1,1:10]
mdatafilename
X<-Read_input_data_from_mFile(mdatafilename)
X[[8]]
mdatafilename
mdatafilename="Mfile_pn390_2.csv"
X<-Read_input_data_from_mFile(mdatafilename)
X[[8]]
X<-Read_input_data_from_mFile(mdatafilename)
tmp_names<-sapply(names(X),function (x) strsplit(x,":")[[1]][2])
sht_tmp_names<-paste0(substr(tmp_names,1,3),substr(tmp_names,nchar(tmp_names),nchar(tmp_names)))
tmp_TP<-sapply(names(X),function (x) strsplit(x,":")[[1]][1])
tmp_TP2<-paste0(substr(tmp_TP,1,1),substr(tmp_TP,nchar(tmp_TP),nchar(tmp_TP)))
## Getting common subject across all layers at a given time point
count=1
com<-list()
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
N<-names(X)[index[1]]
tmp_com<-X[[N]][,ncol(X[[N]])]
for(N in names(X)[index]){
tmp_com<-intersect(tmp_com,X[[N]][,ncol(X[[N]])])
}
com[[count]]<-tmp_com
count=count+1
}
names(com)<-unique(tmp_TP2)
## Reorganisinzing the data to have same rows and appending time point to feature names
X_req<-X
for(time in unique(tmp_TP2)){
index<-which(tmp_TP2==time)
tmp_req_con_mat<-c()
for(N in names(X)[index]){
X_req[[N]]<-X[[N]][match(com[[time]],X[[N]][,ncol(X[[N]])]),] #rearranging the rows
rownames(X_req[[N]])<-com[[time]]
tmp_N<-strsplit(N,":")[[1]][2]
tmp_N2<-paste0(substr(tmp_N,1,3),substr(tmp_N,nchar(tmp_N),nchar(tmp_N)))
colnames(X_req[[N]])<-paste0(colnames(X_req[[N]]),'::',tmp_N2,'_',time) #appending Time point name
tmp<-as.matrix(X_req[[N]])
}
}
X[[8]]
X[[8]][1,1:10]
X_req[[8]][1,1:10]
View(X)
load("/Users/thakurgu/git/Sys_Bio_platform/data/Input/Sepsis/Cytokines/Sepsis_D0_milipore.RData")
load("/Users/thakurgu/git/Sys_Bio_platform/data/Input/Sepsis/Cytokines/STD_log2_transformed_Sepsis_D0_Millipore.RData")
load("/Users/thakurgu/git/Sys_Bio_platform/data/Input/Sepsis/Cytokines/STD_log2_transformed_Sepsis_D0_RandD.RData")
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
getwd()
setwd("/Users/thakurgu/Research/Sepsis_submit/")
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
list.files()
setwd("/Users/thakurgu/Research/Sepsis_submit/Cytokines/")
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
install.packages('glmnet')
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
#load('Normalized_Sepsis_D0.RData')
cyto_mili<-std_datanorm
tmp<-str_replace(colnames(cyto_mili),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_mili<-tmp
colnames(cyto_mili)<-tmp
rownames(cyto_mili)<-paste0("M_",rownames(cyto_mili))
#Cytokine
load("./STD_log2_transformed_Sepsis_D0_RandD.RData")
cyto_RD<-std_datanorm
tmp<-str_replace(colnames(cyto_RD),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_RD<-tmp
colnames(cyto_RD)<-tmp
rownames(cyto_RD)<-paste0("R_",rownames(cyto_RD))
common<-intersect(colnames(cyto_RD),colnames(cyto_mili))
req_cyto_mili<-cyto_mili[,match(common,Name_sepsiscyto_mili)]
req_cyto_RD<-cyto_RD[,match(common,Name_sepsiscyto_RD)]
data<-rbind(req_cyto_mili,req_cyto_RD)
Y<-Y
tmp<-data[,which(Y==0)]
tmp2<-data[,which(Y==1)]
data<-cbind(tmp,tmp2)
Y<-c(Y[which(Y==0)],Y[which(Y==1)])
#####The above is need beacuse"Perform Lasso assume we have "controls"Y=0 followed by "sepsis" (Y=1)
n_folds=5
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
cyto_mili<-std_datanorm
tmp<-str_replace(colnames(cyto_mili),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_mili<-tmp
colnames(cyto_mili)<-tmp
rownames(cyto_mili)<-paste0("M_",rownames(cyto_mili))
#Cytokine
load("./STD_log2_transformed_Sepsis_D0_RandD.RData")
cyto_RD<-std_datanorm
tmp<-str_replace(colnames(cyto_RD),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_RD<-tmp
colnames(cyto_RD)<-tmp
rownames(cyto_RD)<-paste0("R_",rownames(cyto_RD))
common<-intersect(colnames(cyto_RD),colnames(cyto_mili))
req_cyto_mili<-cyto_mili[,match(common,Name_sepsiscyto_mili)]
req_cyto_RD<-cyto_RD[,match(common,Name_sepsiscyto_RD)]
data<-rbind(req_cyto_mili,req_cyto_RD)
Y<-Y
tmp<-data[,which(Y==0)]
tmp2<-data[,which(Y==1)]
data<-cbind(tmp,tmp2)
Y<-c(Y[which(Y==0)],Y[which(Y==1)])
#####The above is need beacuse"Perform Lasso assume we have "controls"Y=0 followed by "sepsis" (Y=1)
n_folds=5
install.packages('randomForest')
librry('stringr')
install.packages('stringr')
librry('stringr')
library('stringr')
rm(list=ls())
library('rlang')
library('randomForest')
#library('umap')
library('pROC')
source('compute_metric.R')
#source('Generate_plots.R')
source('Perform_Lasso.R')
load("./Sepsis_D0_milipore.RData")
load("./STD_log2_transformed_Sepsis_D0_Millipore.RData")
#load('Normalized_Sepsis_D0.RData')
cyto_mili<-std_datanorm
tmp<-str_replace(colnames(cyto_mili),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_mili<-tmp
colnames(cyto_mili)<-tmp
rownames(cyto_mili)<-paste0("M_",rownames(cyto_mili))
#Cytokine
load("./STD_log2_transformed_Sepsis_D0_RandD.RData")
cyto_RD<-std_datanorm
tmp<-str_replace(colnames(cyto_RD),"sepsis.","S")
tmp<-str_replace(tmp,"control.","C")
tmp<-str_replace(tmp,"\\.0","")
Name_sepsiscyto_RD<-tmp
colnames(cyto_RD)<-tmp
rownames(cyto_RD)<-paste0("R_",rownames(cyto_RD))
common<-intersect(colnames(cyto_RD),colnames(cyto_mili))
req_cyto_mili<-cyto_mili[,match(common,Name_sepsiscyto_mili)]
req_cyto_RD<-cyto_RD[,match(common,Name_sepsiscyto_RD)]
data<-rbind(req_cyto_mili,req_cyto_RD)
Y<-Y
tmp<-data[,which(Y==0)]
tmp2<-data[,which(Y==1)]
data<-cbind(tmp,tmp2)
Y<-c(Y[which(Y==0)],Y[which(Y==1)])
#####The above is need beacuse"Perform Lasso assume we have "controls"Y=0 followed by "sepsis" (Y=1)
n_folds=5
library('stringr')
tmp<-Perform_Lasso(data,Y,n_folds,1)
install.packages('randomForest')
install.packages('randomForest')
install.packages('randomForest',version =4.6-14)
urlPackage <- "https://cran.r-project.org/src/contrib/Archive/randomForest/randomForest_4.6-14.tar.gz"
install.packages(urlPackage, repos=NULL, type="source")
install.packages(urlPackage, repos=NULL, type="source")
